package api

import (
	"github.com/labstack/echo/v4"
	"github.com/spf13/cast"
	"longmen/server/pkg/common/api_models"
	"longmen/server/pkg/common/helper/util"
)

// @Summary 搜索直播或主播
// @Description 搜索直播或主播
// @Accept  json
// @Produce  json
// @Tags Search
// @Param   sendBody body api_models.SearchReq true "body"
// @Success 200 {object} api_models.SearchResp "result"
// @Router /api/search [POST]
func (base *Controller) SearchLiveOrAnchor(c echo.Context) error {
	r := &api_models.SearchReq{}
	if err := util.Json2Struct(c.Get("body").(string), r); err != nil {
		return util.BuildFail(c, 1, "", err)
	}
	r.UID = cast.ToInt(c.Get("uid"))
	resp := base.Service.SearchLiveOrAnchor(r)
	return util.BuildSuccess(c, resp, "")
}
